package com.cyf.common.core.io;

import org.springframework.util.ResourceUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * @author chenyifan
 * @create 2024-10-14 15:12
 */
public class PropertiesUtil {

    /**
     * 加载 properties 文件
     * @param resourceLocation 资源路径
     * @return
     */
    public static Properties load(String resourceLocation) throws FileNotFoundException {
        File file = ResourceUtils.getFile(resourceLocation);
        Properties properties = new Properties();
        try (FileInputStream fis = new FileInputStream(file)) {
            properties.load(fis);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return properties;
    }
}